<include file="Public/header" title="个人信息" keywords="{$siteSetting['site_seo_keywords']}" description="{$siteSetting['site_seo_description']}" />

<body class="bg-reglog">
	<!-- FOOTER
    <footer class="x-footer">
		<ul class="x-row x-footer-bar with-border-top">
			<li class="x-col-12-12">
				<a href="javascript:;" class="button button-block button-primary button-large" id="btnAjaxSubmit">确定</a>
			</li>
		</ul>
	</footer> -->
	<!-- /FOOTER -->
	
	<!-- MAIN -->
    <main class="x-content">
		<!-- register -->
	    <section class="x-box reglog">
			<div class="x-box-body">
				<div class="reglog-logo-img">
			        <img src="{$_SESSION['weixinUserInfo']['headimgurl']}" class="img-responsive img-circle" alt="">
				</div>
				
				<form id="form" class="reglog-form">
				<ul class="x-row">
					<li class="x-col-12-12 with-border">
						<div class="x-row">
							<label for="real_name" class="x-col-3-12 x-label-name">姓名</label>
							<input type="text" class="x-col-9-12 x-input-value" name="real_name" id="real_name" placeholder="姓名" value="{$customer.real_name}">
							<input type="hidden" name="id" value="{$customer.id}">
						</div>
					</li>
					<li class="x-col-12-12 with-border">
						<div class="x-row">
							<label for="tel" class="x-col-3-12 x-label-name">手机</label>
							<input type="tel" class="x-col-9-12 x-input-value" name="tel" id="tel" placeholder="手机" value="{$customer.tel}">
						</div>
					</li>
					<li class="x-col-12-12 with-border">
						<div class="x-m-t-15">
							<a href="javascript:;" class="button button-block button-pill button-highlight" id="btnAjaxSubmit">确定</a>
						</div>
					</li>
				</ul>
				<input type="hidden" name="avatar" value="{$_SESSION['weixinUserInfo']['headimgurl']}" />
				<input type="hidden" name="sex" value="{$_SESSION['weixinUserInfo']['sex']}" />
				</form>
			</div>
		</section>
	</main>
	<!-- /MAIN -->

<script type="text/javascript">
$(function () {
	
	// click
	$("#btnAjaxSubmit").click(function() {
		// validate
		if (!$('#real_name').val() || !$('#tel').val()) {
		    xpop({
		       	title: '友情提示',
		        msg: '用户名和手机号必填',
		        buttons: [{
		            text: '完善信息',
		            'class': 'weui_btn_dialog primary',
		            handler: function ($this) {
		        		$this.destroy();
		            }
		        }]
		    });
		    
		    return false;
		}
		
		// update
		var xloading = xpopup.loading();
		$.ajax({
			type: 'post',
			url: "{:U('Customer/Index/doWxEdit')}",
	        contentType: 'application/x-www-form-urlencoded',
			data: $("#form").serialize(),
			dataType: 'json',
			async: false,
			success: function(data) {
				xloading.destroy();
			//	console.log(data);
				if (data.code == 0) {
				   	xpop.toast({
					    type: 'success',
				        msg: '操作成功',
				        delay: 1000,
				        afterClose: function() {
				        	window.location = "{:U('Customer/Index/center')}";
				        }
				    });
				} else {
					xpop({
				       	title: '友情提示',
				        msg: data.msg,
				        buttons: [{
				            text: '确定',
				            'class': 'weui_btn_dialog primary',
				            handler: function ($this) {
				        		$this.destroy();
				            }
				        }]
				    });
				}
			}
		});
	});
});
</script>
</body>
</html>